package com.googlecode.mgwt.expenses.client;

import com.google.gwt.place.shared.Place;
import com.googlecode.mgwt.expenses.client.places.ExpensePlace;
import com.googlecode.mgwt.mvp.client.Animation;
import com.googlecode.mgwt.mvp.client.AnimationMapper;

/**
 * 
 */
public class PhoneAnimationMapper implements AnimationMapper {

	@Override
	public Animation getAnimation(Place oldPlace, Place newPlace) {
		if (oldPlace == null) {
			return Animation.FADE;
		}

		if (oldPlace instanceof ExpensePlace && newPlace instanceof ExpensePlace) {
			ExpensePlace expensePlace = (ExpensePlace) oldPlace;
			if (expensePlace.isDetail()) {
				return Animation.SLIDE_REVERSE;
			} else {
				return Animation.SLIDE;
			}

		}

		return Animation.SLIDE;

	}

}
